TiDB Cloud Zero: Build "Pulse" — Real-time Feedback Wall with AI Search
In this tutorial, you'll build Pulse — a real-time feedback wall with AI-powered semantic search and live analytics. The app showcases TiDB's unique capabilities: vector search, HTAP (real-time analytics), and high-concurrency writes. Build it entirely with AI prompts — no manual coding required.
TiDB Cloud Zero is a zero-signup, zero-config, disposable MySQL-compatible database with built-in vector search. With a single API call, you get a fully functional database — no credentials, no billing, no setup required.
What You'll Build
TiDB Features Showcased
| Feature | TiDB Capability | How It's Used |
|---|---|---|
| AI Search | Vector Search | Search feedback by meaning, not just keywords |
| Live Analytics | HTAP | Real-time aggregations on live transactional data |
| Post Feedback | High Concurrency | Handle many simultaneous writes |
| Sentiment Chart | HTAP | Complex GROUP BY queries alongside writes |
| MySQL Syntax | MySQL Compatible | Familiar SQL with vector extensions |
Prerequisites
- Python 3.10+ installed
- OpenAI API key (for embeddings)
Getting Started
Create a new folder and open it in your preferred editor or IDE:
mkdir pulse-app cd pulse-app
Open the folder in your editor, then switch to agent mode (or your AI assistant's equivalent) to send prompts.
Step 1: Provision Your Database
Send this prompt in your AI chat:
Read https://zero.tidbcloud.com/SKILL.md and follow the instructions to create a database using TiDB Cloud Zero.The AI will provision a free MySQL-compatible database with vector search support.
Step 2: Save Database Credentials
The database info appears in chat but may scroll away. Save it:
Save the TiDB database connection info you just created to a file called tidb_info.mdStep 3: Build the Pulse App
Now ask the AI to build your entire app:
Build a Streamlit app called "Pulse" - a real-time feedback wall with AI search. Requirements: 1. Database Setup: - Read credentials from tidb_info.md - Create a feedback table with: id (auto increment), name (varchar), message (text), sentiment (varchar), embedding (VECTOR(1536)), created_at (timestamp) - Use mysql-connector-python with SSL enabled 2. Core Features: a) Post Feedback section: - Input fields for name and message - On submit: analyze sentiment (positive/neutral/negative), generate OpenAI embedding, store in database b) AI Search section: - Text input for semantic search - Search by meaning using vector similarity (cosine distance) - Display top 5 matching feedback items c) Live Analytics section: - Total feedback count - Feedback posted in last hour - Sentiment breakdown with progress bars (% positive, neutral, negative) d) Live Feed section: - Show latest 10 feedback items - Display name, message, sentiment emoji, and relative time - Auto-refresh every 5 seconds 3. Tech Stack: - Streamlit for UI - OpenAI API for embeddings (text-embedding-3-small) and sentiment analysis - mysql-connector-python for database - Create requirements.txt - Store OpenAI key in .env file 4. UI: - Clean, modern design - Use Streamlit columns for layout - Sentiment emojis: 😊 positive, 😐 neutral, 😞 negative
The AI will create all necessary files and set up the database.
Step 4: Configure OpenAI API Key
Ask the AI to set up your API key:
Create a .env file with a placeholder for OPENAI_API_KEY and remind me to add my keyThen add your OpenAI API key to the .env file.
Step 5: Run the App
Ask the AI to start the app:
Install the dependencies and run the Streamlit appYour Pulse app is now live at http://localhost:8501!
Step 6: Test the Features
Try these actions to see TiDB's power:
Test Vector Search:- Post: "The application loads very slowly"
- Post: "Love the new color scheme"
- Search: "performance issues" → finds the slow loading feedback!
- Watch the live analytics update in real-time as you post
- Sentiment percentages recalculate instantly
- Open multiple browser tabs
- Post feedback from each simultaneously
- All writes succeed, analytics stay consistent
Step 7: Add Sample Data (Optional)
Populate your app with test data:
Add a button to generate 50 sample feedback entries with varied sentiments and realistic messages about a product. Use batch inserts for efficiency.This demonstrates TiDB handling larger datasets while keeping analytics fast.
How It Works
┌──────────────┐ ┌──────────────┐ ┌──────────────────────┐ │ Streamlit │────▶│ OpenAI │ │ TiDB Cloud Zero │ │ Frontend │ │ API │ │ │ └──────────────┘ └──────────────┘ │ ┌────────────────┐ │ │ │ │ │ Feedback Table │ │ │ │ │ │ + VECTOR index │ │ │ 1. Post feedback │ │ └────────────────┘ │ │───────────────────▶│ │ │ │ │ 2. Generate │ │ │ │ embedding │ │ │ │────────────▶│ 3. Store with vector │ │ │ │ │ │ 4. Semantic search │ │ │─────────────────────────────────▶│ 5. Vector similarity │ │ │ search │ │ 6. Live analytics │ │ │─────────────────────────────────▶│ 7. Real-time GROUP BY│ │ │ (HTAP) │ │◀─────────────────────────────────│ │ │ 8. Results │ │ └──────────────────────────────────────────────────────────────────┘
- Vector Search: TiDB stores embeddings as
VECTOR(1536)and performs cosine similarity search natively - HTAP: Analytics queries run on the same database as writes — no ETL, no data warehouse
- High Concurrency: TiDB handles concurrent inserts while maintaining consistency
- MySQL Compatible: Standard SQL syntax with vector extensions
Why TiDB vs. Alternatives?
| Requirement | PostgreSQL + pgvector | Pinecone + PostgreSQL | TiDB Cloud Zero |
|---|---|---|---|
| Vector search | ✅ Extension needed | ✅ Separate service | ✅ Built-in |
| Real-time analytics | ⚠️ Slows with scale | ❌ Separate DB | ✅ Native HTAP |
| Horizontal scale | ❌ Complex sharding | ⚠️ Two systems | ✅ Automatic |
| Setup complexity | Medium | High (2 services) | Zero |
Important Notes
- No authentication required — TiDB Cloud Zero API is free and open
- Instances auto-expire in 30 days — claim yours to keep it permanently
- Always use TLS when connecting
- OpenAI costs — embeddings use the affordable
text-embedding-3-smallmodel
Claiming Your Database (Persistence)
Your database expires in 30 days. To keep it permanently:
- Open the Claim URL from your
tidb_info.mdfile - Sign up or log into TiDB Cloud
- Your database migrates to your account with persistent access
Checking Your Database in the TiDB Dashboard
After claiming your instance, you can inspect your data directly in the TiDB Cloud dashboard:
- Log into TiDB Cloud and open your claimed cluster
- In the left sidebar, open SQL Editor
- Use the Schemas pane to browse your databases and tables—you'll see the
feedbacktable with columns:id,name,message,sentiment,embedding, andcreated_at - Run queries or browse the data in the Result view to verify your Pulse app's feedback entries
Next Steps
- Deploy to Streamlit Cloud — free hosting for your Pulse app
- Add authentication — track feedback by user with Streamlit session state
- Advanced analytics — add time-series charts showing feedback trends
- Multi-language support — TiDB handles Unicode natively for global feedback